package androidx.recyclerview.widget;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.MarginLayoutParams;
import androidx.recyclerview.widget.LinearLayoutManager.a;
import androidx.recyclerview.widget.LinearLayoutManager.c;
import androidx.recyclerview.widget.LinearLayoutManager.d;
import androidx.recyclerview.widget.RecyclerView.o;
import androidx.recyclerview.widget.RecyclerView.t;
import java.util.Arrays;
import o.in;
import o.in$e;

public class GridLayoutManager extends LinearLayoutManager {
    e ʻ = new b();
    final Rect ʼ = new Rect();
    final SparseIntArray ʽ = new SparseIntArray();
    boolean ˊ = false;
    View[] ˋ;
    int[] ˎ;
    int ˏ = -1;
    final SparseIntArray ॱ = new SparseIntArray();

    public static class LayoutParams extends androidx.recyclerview.widget.RecyclerView.LayoutParams {
        int ˊ = -1;
        int ॱ = 0;

        public LayoutParams(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public LayoutParams(int i, int i2) {
            super(i, i2);
        }

        public LayoutParams(MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
        }

        public LayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }

        public int ˏ() {
            return this.ˊ;
        }

        public int ˊ() {
            return this.ॱ;
        }
    }

    public static abstract class e {
        private boolean ˋ = false;
        final SparseIntArray ˏ = new SparseIntArray();

        public abstract int ˏ(int i);

        public void ॱ() {
            this.ˏ.clear();
        }

        int ˏ(int i, int i2) {
            if (!this.ˋ) {
                return ˎ(i, i2);
            }
            int i3 = this.ˏ.get(i, -1);
            if (i3 != -1) {
                return i3;
            }
            i3 = ˎ(i, i2);
            this.ˏ.put(i, i3);
            return i3;
        }

        public int ˎ(int i, int i2) {
            int ˏ = ˏ(i);
            if (ˏ == i2) {
                return 0;
            }
            int ˎ;
            int ˏ2;
            int i3;
            if (this.ˋ && this.ˏ.size() > 0) {
                ˎ = ˎ(i);
                if (ˎ >= 0) {
                    ˏ2 = this.ˏ.get(ˎ) + ˏ(ˎ);
                    ˎ++;
                    i3 = ˎ;
                    while (i3 < i) {
                        ˎ = ˏ(i3);
                        ˏ2 += ˎ;
                        if (ˏ2 == i2) {
                            ˎ = 0;
                        } else if (ˏ2 <= i2) {
                            ˎ = ˏ2;
                        }
                        i3++;
                        ˏ2 = ˎ;
                    }
                    if (ˏ2 + ˏ > i2) {
                        return ˏ2;
                    }
                    return 0;
                }
            }
            ˎ = 0;
            ˏ2 = 0;
            i3 = ˎ;
            while (i3 < i) {
                ˎ = ˏ(i3);
                ˏ2 += ˎ;
                if (ˏ2 == i2) {
                    ˎ = 0;
                } else if (ˏ2 <= i2) {
                    ˎ = ˏ2;
                }
                i3++;
                ˏ2 = ˎ;
            }
            if (ˏ2 + ˏ > i2) {
                return 0;
            }
            return ˏ2;
        }

        int ˎ(int i) {
            int i2 = 0;
            int size = this.ˏ.size() - 1;
            while (i2 <= size) {
                int i3 = (i2 + size) >>> 1;
                if (this.ˏ.keyAt(i3) < i) {
                    i2 = i3 + 1;
                } else {
                    size = i3 - 1;
                }
            }
            size = i2 - 1;
            if (size < 0 || size >= this.ˏ.size()) {
                return -1;
            }
            return this.ˏ.keyAt(size);
        }

        public int ॱ(int i, int i2) {
            int ˏ = ˏ(i);
            int i3 = 0;
            int i4 = 0;
            int i5 = 0;
            while (i3 < i) {
                int ˏ2 = ˏ(i3);
                i5 += ˏ2;
                if (i5 == i2) {
                    i4++;
                    ˏ2 = 0;
                } else if (i5 > i2) {
                    i4++;
                } else {
                    ˏ2 = i5;
                }
                i3++;
                i5 = ˏ2;
            }
            if (i5 + ˏ > i2) {
                return i4 + 1;
            }
            return i4;
        }
    }

    public static final class b extends e {
        public int ˏ(int i) {
            return 1;
        }

        public int ˎ(int i, int i2) {
            return i % i2;
        }
    }

    public GridLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, i2);
        ॱ(ॱ(context, attributeSet, i, i2).ॱ);
    }

    public GridLayoutManager(Context context, int i) {
        super(context);
        ॱ(i);
    }

    public void ˋ(boolean z) {
        if (z) {
            throw new UnsupportedOperationException("GridLayoutManager does not support stack from end. Consider using reverse layout");
        }
        super.ˋ(false);
    }

    public int ˎ(o oVar, t tVar) {
        if (this.ॱॱ == 0) {
            return this.ˏ;
        }
        if (tVar.ˏ() < 1) {
            return 0;
        }
        return ॱ(oVar, tVar, tVar.ˏ() - 1) + 1;
    }

    public int ˊ(o oVar, t tVar) {
        if (this.ॱॱ == 1) {
            return this.ˏ;
        }
        if (tVar.ˏ() < 1) {
            return 0;
        }
        return ॱ(oVar, tVar, tVar.ˏ() - 1) + 1;
    }

    public void ˊ(o oVar, t tVar, View view, in inVar) {
        android.view.ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (layoutParams instanceof LayoutParams) {
            LayoutParams layoutParams2 = (LayoutParams) layoutParams;
            int ॱ = ॱ(oVar, tVar, layoutParams2.ʻ());
            if (this.ॱॱ == 0) {
                int ˏ = layoutParams2.ˏ();
                int ˊ = layoutParams2.ˊ();
                boolean z = this.ˏ > 1 && layoutParams2.ˊ() == this.ˏ;
                inVar.ˋ(in$e.ॱ(ˏ, ˊ, ॱ, 1, z, false));
                return;
            }
            int ˏ2 = layoutParams2.ˏ();
            int ˊ2 = layoutParams2.ˊ();
            boolean z2 = this.ˏ > 1 && layoutParams2.ˊ() == this.ˏ;
            inVar.ˋ(in$e.ॱ(ॱ, 1, ˏ2, ˊ2, z2, false));
            return;
        }
        super.ˏ(view, inVar);
    }

    public void ˋ(o oVar, t tVar) {
        if (tVar.ˋ()) {
            ـ();
        }
        super.ˋ(oVar, tVar);
        ॱʼ();
    }

    public void ˋ(t tVar) {
        super.ˋ(tVar);
        this.ˊ = false;
    }

    private void ॱʼ() {
        this.ॱ.clear();
        this.ʽ.clear();
    }

    private void ـ() {
        int ˈ = ˈ();
        for (int i = 0; i < ˈ; i++) {
            LayoutParams layoutParams = (LayoutParams) ᐝ(i).getLayoutParams();
            int ʻ = layoutParams.ʻ();
            this.ॱ.put(ʻ, layoutParams.ˊ());
            this.ʽ.put(ʻ, layoutParams.ˏ());
        }
    }

    public void ॱ(RecyclerView recyclerView, int i, int i2) {
        this.ʻ.ॱ();
    }

    public void ˎ(RecyclerView recyclerView) {
        this.ʻ.ॱ();
    }

    public void ˊ(RecyclerView recyclerView, int i, int i2) {
        this.ʻ.ॱ();
    }

    public void ˋ(RecyclerView recyclerView, int i, int i2, Object obj) {
        this.ʻ.ॱ();
    }

    public void ˏ(RecyclerView recyclerView, int i, int i2, int i3) {
        this.ʻ.ॱ();
    }

    public androidx.recyclerview.widget.RecyclerView.LayoutParams ॱ() {
        if (this.ॱॱ == 0) {
            return new LayoutParams(-2, -1);
        }
        return new LayoutParams(-1, -2);
    }

    public androidx.recyclerview.widget.RecyclerView.LayoutParams ˏ(Context context, AttributeSet attributeSet) {
        return new LayoutParams(context, attributeSet);
    }

    public androidx.recyclerview.widget.RecyclerView.LayoutParams ˏ(android.view.ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof MarginLayoutParams) {
            return new LayoutParams((MarginLayoutParams) layoutParams);
        }
        return new LayoutParams(layoutParams);
    }

    public boolean ˏ(androidx.recyclerview.widget.RecyclerView.LayoutParams layoutParams) {
        return layoutParams instanceof LayoutParams;
    }

    private void ॱͺ() {
        int ˋˊ;
        if (ॱॱ() == 1) {
            ˋˊ = (ˋˊ() - ˋᐝ()) - ˊˊ();
        } else {
            ˋˊ = (ˉ() - ˍ()) - ˋˋ();
        }
        ˏॱ(ˋˊ);
    }

    public void ॱ(Rect rect, int i, int i2) {
        if (this.ˎ == null) {
            super.ॱ(rect, i, i2);
        }
        int ˋᐝ = ˋᐝ() + ˊˊ();
        int ˋˋ = ˋˋ() + ˍ();
        if (this.ॱॱ == 1) {
            ˋˋ = ˎ(i2, ˋˋ + rect.height(), ˏˎ());
            ˋᐝ = ˎ(i, ˋᐝ + this.ˎ[this.ˎ.length - 1], ͺॱ());
        } else {
            ˋᐝ = ˎ(i, ˋᐝ + rect.width(), ͺॱ());
            ˋˋ = ˎ(i2, ˋˋ + this.ˎ[this.ˎ.length - 1], ˏˎ());
        }
        ʻ(ˋᐝ, ˋˋ);
    }

    private void ˏॱ(int i) {
        this.ˎ = ˎ(this.ˎ, this.ˏ, i);
    }

    static int[] ˎ(int[] iArr, int i, int i2) {
        int i3 = 0;
        if (!(iArr != null && iArr.length == i + 1 && iArr[iArr.length - 1] == i2)) {
            iArr = new int[(i + 1)];
        }
        iArr[0] = 0;
        int i4 = i2 / i;
        int i5 = i2 % i;
        int i6 = 0;
        for (int i7 = 1; i7 <= i; i7++) {
            int i8;
            i3 += i5;
            if (i3 <= 0 || i - i3 >= i5) {
                i8 = i4;
            } else {
                i8 = i4 + 1;
                i3 -= i;
            }
            i6 += i8;
            iArr[i7] = i6;
        }
        return iArr;
    }

    int ˎ(int i, int i2) {
        if (this.ॱॱ == 1 && ʽ()) {
            return this.ˎ[this.ˏ - i] - this.ˎ[(this.ˏ - i) - i2];
        }
        return this.ˎ[i + i2] - this.ˎ[i];
    }

    void ˎ(o oVar, t tVar, c cVar, int i) {
        super.ˎ(oVar, tVar, cVar, i);
        ॱͺ();
        if (tVar.ˏ() > 0 && !tVar.ˋ()) {
            ˋ(oVar, tVar, cVar, i);
        }
        ॱʻ();
    }

    private void ॱʻ() {
        if (this.ˋ == null || this.ˋ.length != this.ˏ) {
            this.ˋ = new View[this.ˏ];
        }
    }

    public int ˊ(int i, o oVar, t tVar) {
        ॱͺ();
        ॱʻ();
        return super.ˊ(i, oVar, tVar);
    }

    public int ˎ(int i, o oVar, t tVar) {
        ॱͺ();
        ॱʻ();
        return super.ˎ(i, oVar, tVar);
    }

    private void ˋ(o oVar, t tVar, c cVar, int i) {
        Object obj = 1;
        if (i != 1) {
            obj = null;
        }
        int ˎ = ˎ(oVar, tVar, cVar.ˎ);
        if (obj != null) {
            while (ˎ > 0 && cVar.ˎ > 0) {
                cVar.ˎ--;
                ˎ = ˎ(oVar, tVar, cVar.ˎ);
            }
            return;
        }
        int ˏ = tVar.ˏ() - 1;
        int i2 = cVar.ˎ;
        int i3 = ˎ;
        while (i2 < ˏ) {
            ˎ = ˎ(oVar, tVar, i2 + 1);
            if (ˎ <= i3) {
                break;
            }
            i2++;
            i3 = ˎ;
        }
        cVar.ˎ = i2;
    }

    View ˎ(o oVar, t tVar, int i, int i2, int i3) {
        View view = null;
        ᐝ();
        int ˏ = this.ᐝ.ˏ();
        int ˊ = this.ᐝ.ˊ();
        int i4 = i2 > i ? 1 : -1;
        View view2 = null;
        while (i != i2) {
            View view3;
            View ᐝ = ᐝ(i);
            int ˎ = ˎ(ᐝ);
            if (ˎ >= 0 && ˎ < i3) {
                if (ˎ(oVar, tVar, ˎ) != 0) {
                    view3 = view;
                    ᐝ = view2;
                } else if (((androidx.recyclerview.widget.RecyclerView.LayoutParams) ᐝ.getLayoutParams()).ॱ()) {
                    if (view2 == null) {
                        view3 = view;
                    }
                } else if (this.ᐝ.ˋ(ᐝ) < ˊ && this.ᐝ.ॱ(ᐝ) >= ˏ) {
                    return ᐝ;
                } else {
                    if (view == null) {
                        view3 = ᐝ;
                        ᐝ = view2;
                    }
                }
                i += i4;
                view = view3;
                view2 = ᐝ;
            }
            view3 = view;
            ᐝ = view2;
            i += i4;
            view = view3;
            view2 = ᐝ;
        }
        if (view == null) {
            view = view2;
        }
        return view;
    }

    private int ॱ(o oVar, t tVar, int i) {
        if (!tVar.ˋ()) {
            return this.ʻ.ॱ(i, this.ˏ);
        }
        int ˏ = oVar.ˏ(i);
        if (ˏ != -1) {
            return this.ʻ.ॱ(ˏ, this.ˏ);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. " + i);
        return 0;
    }

    private int ˎ(o oVar, t tVar, int i) {
        if (!tVar.ˋ()) {
            return this.ʻ.ˏ(i, this.ˏ);
        }
        int i2 = this.ʽ.get(i, -1);
        if (i2 != -1) {
            return i2;
        }
        i2 = oVar.ˏ(i);
        if (i2 != -1) {
            return this.ʻ.ˏ(i2, this.ˏ);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i);
        return 0;
    }

    private int ˋ(o oVar, t tVar, int i) {
        if (!tVar.ˋ()) {
            return this.ʻ.ˏ(i);
        }
        int i2 = this.ॱ.get(i, -1);
        if (i2 != -1) {
            return i2;
        }
        i2 = oVar.ˏ(i);
        if (i2 != -1) {
            return this.ʻ.ˏ(i2);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i);
        return 1;
    }

    void ˎ(t tVar, d dVar, androidx.recyclerview.widget.RecyclerView.j.b bVar) {
        int i = this.ˏ;
        for (int i2 = 0; i2 < this.ˏ && dVar.ˊ(tVar) && i > 0; i2++) {
            int i3 = dVar.ˏ;
            bVar.ˎ(i3, Math.max(0, dVar.ॱॱ));
            i -= this.ʻ.ˏ(i3);
            dVar.ˏ += dVar.ˎ;
        }
    }

    void ˎ(o oVar, t tVar, d dVar, a aVar) {
        int ᐝ = this.ᐝ.ᐝ();
        Object obj = ᐝ != 1073741824 ? 1 : null;
        int i = ˈ() > 0 ? this.ˎ[this.ˏ] : 0;
        if (obj != null) {
            ॱͺ();
        }
        boolean z = dVar.ˎ == 1;
        int i2 = 0;
        int i3 = 0;
        int i4 = this.ˏ;
        if (!z) {
            i4 = ˎ(oVar, tVar, dVar.ˏ) + ˋ(oVar, tVar, dVar.ˏ);
        }
        while (i2 < this.ˏ && dVar.ˊ(tVar) && i4 > 0) {
            int i5 = dVar.ˏ;
            int ˋ = ˋ(oVar, tVar, i5);
            if (ˋ <= this.ˏ) {
                i4 -= ˋ;
                if (i4 >= 0) {
                    View ˊ = dVar.ˊ(oVar);
                    if (ˊ == null) {
                        break;
                    }
                    i3 += ˋ;
                    this.ˋ[i2] = ˊ;
                    i2++;
                } else {
                    break;
                }
            }
            throw new IllegalArgumentException("Item at position " + i5 + " requires " + ˋ + " spans but GridLayoutManager has only " + this.ˏ + " spans.");
        }
        if (i2 == 0) {
            aVar.ˎ = true;
            return;
        }
        LayoutParams layoutParams;
        int i6;
        int ˎ;
        ॱ(oVar, tVar, i2, i3, z);
        i3 = 0;
        float f = 0.0f;
        i5 = 0;
        while (i3 < i2) {
            View view = this.ˋ[i3];
            if (dVar.ॱˊ == null) {
                if (z) {
                    ˊ(view);
                } else {
                    ˊ(view, 0);
                }
            } else if (z) {
                ॱ(view);
            } else {
                ˏ(view, 0);
            }
            ˊ(view, this.ʼ);
            ˊ(view, ᐝ, false);
            i4 = this.ᐝ.ˊ(view);
            if (i4 > i5) {
                i5 = i4;
            }
            float ᐝ2 = (((float) this.ᐝ.ᐝ(view)) * 1.0f) / ((float) ((LayoutParams) view.getLayoutParams()).ॱ);
            if (ᐝ2 <= f) {
                ᐝ2 = f;
            }
            i3++;
            f = ᐝ2;
        }
        if (obj != null) {
            ˏ(f, i);
            i5 = 0;
            ˋ = 0;
            while (ˋ < i2) {
                View view2 = this.ˋ[ˋ];
                ˊ(view2, 1073741824, true);
                i4 = this.ᐝ.ˊ(view2);
                if (i4 <= i5) {
                    i4 = i5;
                }
                ˋ++;
                i5 = i4;
            }
        }
        for (i3 = 0; i3 < i2; i3++) {
            View view3 = this.ˋ[i3];
            if (this.ᐝ.ˊ(view3) != i5) {
                layoutParams = (LayoutParams) view3.getLayoutParams();
                Rect rect = layoutParams.ˏ;
                i6 = ((rect.top + rect.bottom) + layoutParams.topMargin) + layoutParams.bottomMargin;
                ˋ = ((rect.right + rect.left) + layoutParams.leftMargin) + layoutParams.rightMargin;
                ˎ = ˎ(layoutParams.ˊ, layoutParams.ॱ);
                if (this.ॱॱ == 1) {
                    ˋ = ˋ(ˎ, 1073741824, ˋ, layoutParams.width, false);
                    i4 = MeasureSpec.makeMeasureSpec(i5 - i6, 1073741824);
                } else {
                    ˋ = MeasureSpec.makeMeasureSpec(i5 - ˋ, 1073741824);
                    i4 = ˋ(ˎ, 1073741824, i6, layoutParams.height, false);
                }
                ˏ(view3, ˋ, i4, true);
            }
        }
        aVar.ˊ = i5;
        i4 = 0;
        if (this.ॱॱ == 1) {
            if (dVar.ᐝ == -1) {
                i4 = dVar.ˊ;
                i5 = i4 - i5;
                ˋ = 0;
                i3 = 0;
            } else {
                ˋ = dVar.ˊ;
                i4 = ˋ + i5;
                i5 = ˋ;
                ˋ = 0;
                i3 = 0;
            }
        } else if (dVar.ᐝ == -1) {
            i3 = dVar.ˊ;
            ˋ = i3;
            i3 -= i5;
            i5 = 0;
        } else {
            i3 = dVar.ˊ;
            ˋ = i5 + i3;
            i5 = 0;
        }
        i = i4;
        ˎ = i5;
        int i7 = ˋ;
        i6 = i3;
        for (i5 = 0; i5 < i2; i5++) {
            view3 = this.ˋ[i5];
            layoutParams = (LayoutParams) view3.getLayoutParams();
            if (this.ॱॱ != 1) {
                ˎ = ˋˋ() + this.ˎ[layoutParams.ˊ];
                i = ˎ + this.ᐝ.ᐝ(view3);
            } else if (ʽ()) {
                i7 = ˊˊ() + this.ˎ[this.ˏ - layoutParams.ˊ];
                i6 = i7 - this.ᐝ.ᐝ(view3);
            } else {
                i6 = ˊˊ() + this.ˎ[layoutParams.ˊ];
                i7 = i6 + this.ᐝ.ᐝ(view3);
            }
            ˋ(view3, i6, ˎ, i7, i);
            if (layoutParams.ॱ() || layoutParams.ˎ()) {
                aVar.ˏ = true;
            }
            aVar.ॱ |= view3.hasFocusable();
        }
        Arrays.fill(this.ˋ, null);
    }

    private void ˊ(View view, int i, boolean z) {
        int ˋ;
        LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
        Rect rect = layoutParams.ˏ;
        int i2 = ((rect.top + rect.bottom) + layoutParams.topMargin) + layoutParams.bottomMargin;
        int i3 = layoutParams.rightMargin + ((rect.right + rect.left) + layoutParams.leftMargin);
        int ˎ = ˎ(layoutParams.ˊ, layoutParams.ॱ);
        if (this.ॱॱ == 1) {
            ˎ = ˋ(ˎ, i, i3, layoutParams.width, false);
            ˋ = ˋ(this.ᐝ.ʻ(), ˊᐝ(), i2, layoutParams.height, true);
        } else {
            int ˋ2 = ˋ(ˎ, i, i2, layoutParams.height, false);
            ˎ = ˋ(this.ᐝ.ʻ(), ˊˋ(), i3, layoutParams.width, true);
            ˋ = ˋ2;
        }
        ˏ(view, ˎ, ˋ, z);
    }

    private void ˏ(float f, int i) {
        ˏॱ(Math.max(Math.round(((float) this.ˏ) * f), i));
    }

    private void ˏ(View view, int i, int i2, boolean z) {
        boolean ˎ;
        androidx.recyclerview.widget.RecyclerView.LayoutParams layoutParams = (androidx.recyclerview.widget.RecyclerView.LayoutParams) view.getLayoutParams();
        if (z) {
            ˎ = ˎ(view, i, i2, layoutParams);
        } else {
            ˎ = ॱ(view, i, i2, layoutParams);
        }
        if (ˎ) {
            view.measure(i, i2);
        }
    }

    private void ॱ(o oVar, t tVar, int i, int i2, boolean z) {
        int i3;
        int i4;
        if (z) {
            i3 = 1;
            i4 = 0;
        } else {
            i3 = i - 1;
            i = -1;
            i4 = i3;
            i3 = -1;
        }
        int i5 = 0;
        for (int i6 = i4; i6 != i; i6 += i3) {
            View view = this.ˋ[i6];
            LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
            layoutParams.ॱ = ˋ(oVar, tVar, ˎ(view));
            layoutParams.ˊ = i5;
            i5 += layoutParams.ॱ;
        }
    }

    public int ˎ() {
        return this.ˏ;
    }

    public void ॱ(int i) {
        if (i != this.ˏ) {
            this.ˊ = true;
            if (i < 1) {
                throw new IllegalArgumentException("Span count should be at least 1. Provided " + i);
            }
            this.ˏ = i;
            this.ʻ.ॱ();
            ॱˋ();
        }
    }

    public View ˎ(View view, int i, o oVar, t tVar) {
        View ˏ = ˏ(view);
        if (ˏ == null) {
            return null;
        }
        LayoutParams layoutParams = (LayoutParams) ˏ.getLayoutParams();
        int i2 = layoutParams.ˊ;
        int i3 = layoutParams.ˊ + layoutParams.ॱ;
        if (super.ˎ(view, i, oVar, tVar) == null) {
            return null;
        }
        int ˈ;
        int i4;
        int i5;
        if (((ʽ(i) == 1) != this.ˏॱ ? 1 : null) != null) {
            ˈ = ˈ() - 1;
            i4 = -1;
            i5 = -1;
        } else {
            ˈ = 0;
            i4 = 1;
            i5 = ˈ();
        }
        Object obj = (this.ॱॱ == 1 && ʽ()) ? 1 : null;
        View view2 = null;
        int i6 = -1;
        int i7 = 0;
        View view3 = null;
        int i8 = -1;
        int i9 = 0;
        int ॱ = ॱ(oVar, tVar, ˈ);
        int i10 = ˈ;
        while (i10 != i5) {
            ˈ = ॱ(oVar, tVar, i10);
            View ᐝ = ᐝ(i10);
            if (ᐝ == ˏ) {
                break;
            }
            View view4;
            int min;
            View view5;
            int i11;
            if (ᐝ.hasFocusable() && ˈ != ॱ) {
                if (view2 != null) {
                    break;
                }
            }
            layoutParams = (LayoutParams) ᐝ.getLayoutParams();
            int i12 = layoutParams.ˊ;
            int i13 = layoutParams.ˊ + layoutParams.ॱ;
            if (ᐝ.hasFocusable() && i12 == i2 && i13 == i3) {
                return ᐝ;
            }
            Object obj2 = null;
            if (!(ᐝ.hasFocusable() && view2 == null) && (ᐝ.hasFocusable() || view3 != null)) {
                int min2 = Math.min(i13, i3) - Math.max(i12, i2);
                if (ᐝ.hasFocusable()) {
                    if (min2 > i7) {
                        obj2 = 1;
                    } else if (min2 == i7) {
                        if (obj == (i12 > i6 ? 1 : null)) {
                            obj2 = 1;
                        }
                    }
                } else if (view2 == null && ˋ(ᐝ, false, true)) {
                    if (min2 > i9) {
                        obj2 = 1;
                    } else if (min2 == i9) {
                        if (obj == (i12 > i8 ? 1 : null)) {
                            obj2 = 1;
                        }
                    }
                }
            } else {
                obj2 = 1;
            }
            if (obj2 != null) {
                if (ᐝ.hasFocusable()) {
                    i7 = layoutParams.ˊ;
                    int i14 = i9;
                    i9 = i8;
                    view4 = view3;
                    min = Math.min(i13, i3) - Math.max(i12, i2);
                    ˈ = i14;
                    int i15 = i7;
                    view5 = ᐝ;
                    i11 = i15;
                } else {
                    i9 = layoutParams.ˊ;
                    ˈ = Math.min(i13, i3) - Math.max(i12, i2);
                    view4 = ᐝ;
                    min = i7;
                    i11 = i6;
                    view5 = view2;
                }
                i10 += i4;
                view2 = view5;
                i7 = min;
                i6 = i11;
                view3 = view4;
                i8 = i9;
                i9 = ˈ;
            }
            ˈ = i9;
            i11 = i6;
            i9 = i8;
            view4 = view3;
            min = i7;
            view5 = view2;
            i10 += i4;
            view2 = view5;
            i7 = min;
            i6 = i11;
            view3 = view4;
            i8 = i9;
            i9 = ˈ;
        }
        if (view2 == null) {
            view2 = view3;
        }
        return view2;
    }

    public boolean ˏ() {
        return this.ˊॱ == null && !this.ˊ;
    }
}
